R basics I — R & RStudio
2025-02-12
At the end of this topic you should be able to
Understand the main features of the RStudio IDE
Run simple R commands in RStudio
Understand the basic syntax of R
Understand how to use the R help system
R is a powerful software application for statistical analysis
It is incredibly popular
R is an interpreted language unlike C, C++, etc
Slower but more forgiving and interactive
RStudio is a powerful integrated development environment (IDE) for R
It is also open source
RStudio ≠ R
Can run RStudio on your computer or in the cloud using posit.cloud
RStudio PBC provide paid-for support & Pro-level versions for organisations
penguins |>
group_by(species) |>
summarize(across(where(is.numeric), mean, na.rm = TRUE))
## # A tibble: 3 × 6
## species bill_length_mm bill_depth_mm flipper_length_mm body_mass_g year
## <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Adelie 38.8 18.3 190. 3701. 2008.
## 2 Chinstrap 48.8 18.4 196. 3733. 2008.
## 3 Gentoo 47.5 15.0 217. 5076. 2008.Don’t worry! You won’t understand most of that!
By the end of the course you will
<- is the assignment operator
Made up from the < and - characters
output <- input
Assign the result of the right hand side to the object named on the left
This creates an object with name output
Refer to objects using their name
The main data types in R are
' or double " quotesTRUE and FALSEAs well as <- R has many operators
Mathematical
+-*/Boolean
< and ><= and >= (< = & > =)== (= =)!= (! =)& AND| OR! NOTCan get help on R from many places
Inside R use ?topic to get help on topic topic
Usually topic is a function
Can search more broadly with ??topic
Other sources: